<template>
    <el-aside width="$store.state.isCollapsed?'64px':'240px'">
        <el-menu :default-active="route.fullPath" :router="true" :collapse="$store.state.isCollapsed"
            :collapse-transition="false" class="el-menu-vertical-demo">
            <el-menu-item index="/index">
                <el-icon>
                    <HomeFilled />
                </el-icon>
                <span>首页</span>
            </el-menu-item>
            <el-menu-item index="/center">
                <el-icon>
                    <avatar />
                </el-icon>
                <span>个人中心</span>
            </el-menu-item>
            <el-sub-menu index="/user-manage" v-admin>
                <template #title>
                    <el-icon><user-filled /></el-icon>
                    <span>用户管理</span>
                </template>
                <el-menu-item index="/user-manage/adduser">
                    <el-icon>
                        <avatar />
                    </el-icon>
                    <span>添加用户</span>
                </el-menu-item>
                <el-menu-item index="/user-manage/userlist">
                    <el-icon>
                        <avatar />
                    </el-icon>
                    <span>用户列表</span>
                </el-menu-item>
            </el-sub-menu>
            <el-sub-menu index="/news-manage">
                <template #title>
                    <el-icon><message-box /></el-icon>
                    <span>新闻管理</span>
                </template>
                <el-menu-item index="/news-manage/addnews">
                    <el-icon>
                        <avatar />
                    </el-icon>
                    <span>创建新闻</span>
                </el-menu-item>
                <el-menu-item index="/news-manage/newslist">
                    <el-icon>
                        <avatar />
                    </el-icon>
                    <span>新闻列表</span>
                </el-menu-item>
            </el-sub-menu>
            <el-sub-menu index="/product-manage">
                <template #title>
                    <el-icon>
                        <Reading />
                    </el-icon>
                    <span>产品管理</span>
                </template>
                <el-menu-item index="/product-manage/addproduct">
                    <el-icon>
                        <avatar />
                    </el-icon>
                    <span>添加产品</span>
                </el-menu-item>
                <el-menu-item index="/product-manage/productlist">
                    <el-icon>
                        <avatar />
                    </el-icon>
                    <span>产品列表</span>
                </el-menu-item>
            </el-sub-menu>
        </el-menu>
    </el-aside>
</template>

<script setup>
import { HomeFilled, Avatar, UserFilled, MessageBox, Reading, Pointer } from '@element-plus/icons-vue'
import { useRoute } from 'vue-router'
import { useStore } from 'vuex'

const store = useStore()
const route = useRoute()

const vAdmin = {
    mounted(el) {
        // console.log(el);
        if(store.state.userInfo.role !== 1){
            el.parentNode.removeChild(el)
        }
    }
}
</script>

<style lang="scss" scoped>
.el-aside {
    height: 100vh;
    // background-color: red;

    .el-menu {
        height: 100vh;
    }
}
</style>